<include file="Admin/header"/>


<div class="content">
		
        <div class="content_search" id="content_search">
            <input type="text" placeholder=" 请输入梦想标题或内容" id="search" class="w250 h24 searchinput" value="{$Think.get.search}">
            <input type="submit" onclick="search();return false;" value="搜索" class="btn">
        </div>
        <a href="/Admin/outPutDream">导出梦想</a>
  	<div id="gd_page_list">
  	<div class="content_table mt10 mb10" style="clear:both;">
    <table class="mb10" style="font-size: 14px;">
		<tbody>
		  <tr style="background: none repeat scroll 0% 0% rgb(232, 249, 255);">
		  	<!-- <th width="5%"><input type="checkbox" id="selectAll" /></th> -->
	        <th width="5%">序号</th>
	        <th>梦想标题</th>
	       	<th width="6%">支持数</th>
	        <th width="6%">浏览数</th>
	        <th width="7%">发布者</th>
	        <th width="11%">手机号</th>
	        <th>商学院 | 年级</th>
	        <th width="5%">关注</th>
	        <th width="8%">操作</th>
	      </tr>
			<notempty name="_list">
				<volist name="_list" id="vo" key="k">
	      <tr>
	      	<!-- <td><input type="checkbox" name="member_id" value="<$vo.member_id>"/></td> -->
	        <td>{$k}</td>
	        <td>{$vo.dream_title}</td>
			<td>{$vo.suport_count}</td>
			<td>0</td>
	        <td>{$vo.user_name}</td>
	        <td>{$vo.user_phone}</td>
	        <td>
	        	<volist name="vo.school" id="von">
	        	{$von.school_name} | {$von.grade_name}<br />
	        	</volist>
	        </td>
	        <td>0</td>
			<td name="yincang">
				<a href="/Admin/editDream?dream_id={$vo.dream_id}">编辑</a>
				<a href="#" onclick="delDream({$vo.dream_id});return false;">删除</a>
				
				<!-- <span id="group_name_{$vo.user_id}"></span> -->
			</td>
	      </tr>
				</volist>
			<else/>
				<tr>
					<th colspan="9" class="taskStatus">暂无数据</th>
				</tr>
			</notempty>
		</tbody>
		</table>
	
</div>

<!-- 分页 start-->
<div style="clear:both;"></div>
<div class="manu" id="ajax_page_end">{$_page}</div>
<!-- <div class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_full_numbers" id="DataTables_Table_0_paginate">
	{$_page}
</div> -->
	</div>
  
</div>


<script type="text/javascript">
	
	function search(){
        var search = $('#search').val();
        var grouping_id = $('select[name="grouping_search"] option:selected').val();
        window.location.href = "/Admin/index?search="+search+"&grouping_id="+grouping_id;
	}

	//删除新闻OR活动
	function delDream(dream_id){
		var gnl=confirm("你确定要删除这条记录吗？");
		if (gnl==true){
			// 执行确定的操作
			if(dream_id == '' || dream_id == undefined || dream_id==0){
				alert('删除记录ID不能为空')
				return false;
			}
			//提交参数
			var data = {
				dream_id: dream_id
			};
			$.post("/Admin/delDream", data,function(result){
				if(result.status == '0'){
					alert(result.info);
					setTimeout(function(){
						window.location.reload();
					},1000);
				}else{
					alert(result.info);
					return false;
				}
			},"json");
		}
	}

	//置顶OR取消
	function setHead(active_id,type){
		var dialog_word;
		//置顶
		if(type=='1'){
			dialog_word = '确定要置顶吗？';
		}else{
			dialog_word = '确定要取消置顶吗？';
		}		
		art.dialog.confirm(dialog_word, function () {
			// 执行确定的操作
			if(active_id == '' || active_id == 'undefined'){
				art.dialog({content:'记录的ID不能为空！'});
				return false;
			}
			//提交参数
			var data = {
				is_head : type,
				active_id: active_id
			};
			$.post("/Active/setHead", data,function(result){
				if(result.status == 'LEARN_1091' || result.status == 'LEARN_1089'){
					art.dialog({content:result.info});
					setTimeout(function(){
						window.location.reload();
					},1000);
				}else{
					art.dialog({content:result.info});
					return false;
				}
			},"json");
			
		}, function () {
			//隐藏弹出框，不做任何操作
			this.close();
		    return false;//执行取消的操作，这里不执行任何操作
		});
	}
	//批量删除
	$('#delAll').click(function(){
			var all_member_id =new Array();
			var i=0;
			$("input[name=member_id]").each(function(){
				if($(this).prop("checked")){
					all_member_id[i]=$(this).val();
					++i;
				}
			});
		//console.log(member_list);return false;
			if(all_member_id==''){
				art.dialog({time:1,content: '请选择人员'});
				return false;
			}
			var all_member_ids = implode(',',all_member_id);
			var json_data = {
					all_member_ids	:	all_member_ids,
			}
			$.ajax({
				type: "POST",
				url: "{:U('/index.php/Leadership/deleteAll')}?rand="+Math.random(),
				data: json_data,
				dataType:'json',
				success:function(call_back){
					if( 'LEARN_1023' == call_back.status){
						art.dialog({time:1,content: call_back.info});
						//location.href=call_back.url;
						setTimeout(function(){
							window.location.href='__APP__/Leadership/leadershipIndex';
						},300);//延时时间300ms
					}else{
						art.dialog({time:1,content: call_back.info});
					}
					return false;
				}
			});
		});
	
	function joinGroup(user_id){
		var f_title = '';
		f_title = '分组';
		
		var dialog_a = art.dialog({id:'N3690',title: f_title});
		
		$.ajax({
		    url: '/Admin/joinGroup',
		    data: "user_id="+user_id,
		    type: 'post',
		    success: function (call_back) {
		    	dialog_a.content(call_back);
		    },
		    cache: false,
		    dataType: "html"
		});
	}

	function joinGroupSubmit(){
		var grouping_id = $('select[name="grouping_id"] option:selected').val();
		var user_id = $("#user_id").val();
		var group_id_old = $("#group_id_old").val();
		if ((grouping_id == '' || grouping_id == undefined) || (group_id_old == "" && grouping_id == 0)) {
			art.dialog({content:'请选择分组后提交'});
			return false;
		}
		var json_data = {
			user_id : user_id, 
			grouping_id : grouping_id,
			group_id_old : group_id_old
		}
		$.post("/Admin/joinGroupSubmit?rand=" + Math.random(), json_data, function(data) {
			if (data.status == '1') {
				art.dialog({
				    content: data.info,time:1
				});
				window.top.art.dialog({id:'N3690'}).close();
				return false;
			}else {
				art.dialog({content: data.info,time:1});
				window.top.art.dialog({id:'N3690'}).close();
				getGroupName(user_id);
				return false;
				//window.location.reload();
			}
			return false;
		}, "json");
	}
	
	function getGroupName(user_id){
		var json_data = {
				user_id : user_id
			}
			$.post("/Admin/getGroupName?rand=" + Math.random(), json_data, function(data) {
				if (data.status == '0') {

					if(data.data == null){
						$("#group_name_"+user_id).html("分组");
					}else{
						$("#group_name_"+user_id).html(data.data);
					}
					return false;
				}
				return false;
			}, "json");
	}
</script>
<script type="text/javascript" src="__PUBLIC__/Home/js/tr.js"></script>
